# coding:utf-8

import webbrowser as web
import time
import os
import csv

a = 1

if __name__ == '__main__' and a > 2:
  print('hi python')
elif a == 1:
  print(a)

print('--------- while ------------')

b = 0
s = 0
while b < 100:
  b = b + 1
  s = b + s
else:
  print(b, s)

# b = 0
# while b < 15:
#   web.open_new_tab('http://www.baidu.com')
#   b = b + 1
#   time.sleep(0.8)
# else:
#   os.system('taskkill /F /IM chrome.exe')

# print('down')

numbers = [12, 37, 5, 42, 8, 3]
even = []
odd = []

while len(numbers):
  n = numbers.pop()
  if(n % 2 == 0):
    even.append(n)
  else:
    odd.append(n)

print(even)
print(odd)


def readFile():
  file = open('./file/test1.txt', 'a', encoding='utf8')
  file.write('xxxxxx\n')
  file.close()

  outfile2 = open('./file/test1.txt','a',encoding="utf8")
  outfile2.writelines(['hello',' ','world','\n'])
  outfile2.close()

  infile = open('./file/test1.txt', 'r', encoding="utf8")
  for line in infile.readlines():
    print(line)

  c = open('./file/test1.csv', 'w', encoding='utf8', newline='')
  writer = csv.writer(c)
  writer.writerow(['zz','xx','cc'])

  writer.writerow(['1','q','a'])
  writer.writerow(['2','w','s'])
  writer.writerow(['3','e','d'])

  c.close()


readFile()